import axios from "axios";

let baseURL = process.env.VUE_APP_FIATBEURL

function getToken() {
    return axios({
        url: `${baseURL}/api/auth/token`,
        method: 'POST',
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        },
        data: {
            username: 'prepan01:prepan01@outlook.com',
            password: 'prepanprepan'
        }
    })
}

let fiatBE = axios.create({
    baseURL,
});

fiatBE.interceptors.request.use(async config => {
    let token = await getToken()
    config.headers.Authorization = `Bearer ${token.data.access_token}`
    return config
})

export default fiatBE
